package com.learn.springcloud.hystrixexplainindetailconsumer.request.collapser.service.impl;

import com.learn.springcloud.hystrixexplainindetailconsumer.request.collapser.service.RequestCollapserExtendService;
import com.learn.springcloud.hystrixexplainindetailconsumer.bean.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
 * @Time : 2018/8/6 17:09
 * @Version : 1.0
 * @Author : hongyan.li@hand-china.com
 * Copyright @ 2000 Shanghai Hand Co. Ltd.
 * All right reserved.
 */
@Service
public class RequestCollapserServiceExtendImpl implements RequestCollapserExtendService {

    @Autowired
    private RestTemplate restTemplate;

    @Override
    public User find(Long id) {
        System.out.println(id);
        return restTemplate.getForObject("http://hystrix-explain-in-detail-provider/request/collpaser/find/user/{1}", User.class, id);
    }

    @Override
    public List<User> finds(List<Long> ids) {
        System.out.println(ids);
        String url = "http://hystrix-explain-in-detail-provider/request/collpaser/find/users?ids={1}";
       List list = restTemplate.getForObject(url, List.class, ids);
        return list;
    }
}
